import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/home/Home.vue'


Vue.use(VueRouter)

// eslint-disable-next-line no-sparse-arrays
const routes = [{
    path: '/',
    name: 'Home',
    component: Home,

  },
  {
    path: '/search',
    name: 'Search',
    component: () => import( /* webpackChunkName: "about" */ '../views/home/Search.vue')
  },
  {
    path: '/yejiao',
    name: 'Yejiao',
    component: () => import( /* webpackChunkName: "about" */ '../components/Yejiao.vue')
  },
  //消息主页
  {
    path: '/news',
    name: 'News',
    component: () => import( /* webpackChunkName: "about" */ '../views/news/News.vue')
  },
  // 消息子页
  {
    path: '/newslist',
    name: 'NewsList',
    component: () => import( /* webpackChunkName: "about" */ '../views/news/NewsList.vue')
  },
  {
    // 登录页面
    path: '/MobilePhone',
    name: 'MobilePhone',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import( /* webpackChunkName: "about" */ '../views/my/MobilePhone.vue')
  },
  {
    // 我的买车页面
    path: '/BoughtACar',
    name: 'BoughtACar',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import( /* webpackChunkName: "about" */ '../views/my/BoughtACar.vue')
  },
  // my
  {
    path: '/my',
    name: 'my',
    component: () => import( /* webpackChunkName: "about" */ '../views/my/Personal_page.vue')
  },
  // set
  {
    path: '/set',
    name: 'set',
    component: () => import( /* webpackChunkName: "about" */ '../views/my/Set_up.vue')
  },
  /* 列表页面 */
  {
    path: '/carList',
    name: 'CarList',
    component: () => import( /* webpackChunkName: "about" */ './../views/home/CarList.vue')
  },
  {
    // 一键登录页面
    path: '/OneClickLogin',
    name: 'OneClickLogin',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import( /* webpackChunkName: "about" */ '../views/my/OneClickLogin.vue')
  },
  {
    // 注册页面
    path: '/Register',
    name: 'Register',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import( /* webpackChunkName: "about" */ '../views/my/Register.vue')
  },


  /* 收藏页面 */
  {
    path: '/Collection',
    name: 'Collection',
    component: () => import( /* webpackChunkName: "about" */ './../views/collection/Collection.vue')
  },
  // 卖车页面
  {
    path: '/Sellingcars',
    name: 'Sellingcars',
    component: () => import( /* webpackChunkName: "about" */ './../views/selling/Sellingcars.vue')
  },
  // 卖车子页面
  {
    path: '/details',
    name: 'details',
    component: () => import( /* webpackChunkName: "about" */ '../views/selling/Details.vue')
  },
  {
    // 车辆详情页面
    path: '/CarDetails',
    name: 'CarDetails',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import( /* webpackChunkName: "about" */ '../views/home/CarDetails.vue')
  },
]


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,

  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      } //期望滚动到哪个的位置
    }
  },
})


export default router